<!DOCTYPE html>
<html lang="en"><head><script async="" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/cbgapi.loaded_0"></script><script gapi_processed="true" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/plusone.js" async="" type="text/javascript"></script><script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/ga.js" async="" type="text/javascript"></script><script async="" charset="UTF-8" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/get" type="text/javascript"></script>
  <title>On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API - Scott Hanselman</title>
 	<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
	<meta name="title" content="On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API - Scott Hanselman">
	<meta name="author" content="Scott Hanselman">
	<meta name="copyright" content="Scott Hanselman">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta content="Scott, Computer, Zen, .NET, C#, Hanselman, Microsoft, Scott, Weblog, Diabetes, Portland, Zimbabwe, ASP.NET, Azure, Cloud, Productivity, Hanselman" name="keywords">
	<meta name="description" content="Scott Hanselman on Programming, The Web, Open Source, .NET, The Cloud and More">
	<link rel="meta" type="application/rdf+xml" title="FOAF" href="http://www.hanselman.com/blog/foaf.rdf">
		
	<link rel="stylesheet" type="text/css" href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/supportingstyles.css" media="screen">
  <link rel="stylesheet" type="text/css" href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/style.css" media="screen">
  <link rel="stylesheet" type="text/css" href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/print.css" media="print">

	<link href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/css_004.css" rel="stylesheet" type="text/css">    
	<link href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/css.css" rel="stylesheet" type="text/css">
	<link href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/css_003.css" rel="stylesheet" type="text/css">   
	<link href="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/css_002.css" rel="stylesheet" type="text/css">
		 
	<!--[if IE]>
	<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
	<![endif]-->  
  <meta name="application-name" content="Scott Hanselman's Blog">
  <meta name="msapplication-config" content="/browserconfig.xml">
  <link rel="shortcut icon" href="http://www.hanselman.com/images/favicon.ico">
	<link rel="apple-touch-icon" href="http://www.hanselman.com/images/apple-touch-icon.png">
	<link rel="apple-touch-icon" sizes="72x72" href="http://www.hanselman.com/images/apple-touch-icon-72x72.png">
	<link rel="apple-touch-icon" sizes="114x114" href="http://www.hanselman.com/images/apple-touch-icon-114x114.png">
	<link rel="icon" href="http://www.hanselman.com/images/apple-touch-icon.png">
  <link rel="alternate" type="application/rss+xml" title="Scott Hanselman's Blog" href="http://feeds.hanselman.com/ScottHanselman">
	<link rel="me" type="text/html" href="https://plus.google.com/108573066018819777334?rel=me"> 
	<link rel="me" type="text/html" href="http://feeds.hanselman.com/ScottHanselman"> 
	<link rel="me" type="text/html" href="https://twitter.com/shanselman"> 
	<link rel="me" type="text/html" href="https://facebook.com/scott.hanselman"> 
	<meta name="t_omni_extblogid" content="msstoextblogs1">
	<meta name="t_omni_blogname" content="Scott Hanselman">
	<link rel="search" type="application/opensearchdescription+xml" href="http://www.hanselman.com/blog/opensearch.xml" title="Hanselman Search">
	<meta name="msapplication-starturl" content="./">
  <meta name="msapplication-TileImage" content="/blog/images/hanselman-144.png">
 <script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/outbrainLT.js" async="" type="text/javascript"></script><script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/jquery-1.js"></script>
<script>
  (window.jQuery || document.write('<script src="/blog/scripts/jquery.1.4.min.js"><\/script>'));
</script>
 <script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/header.js"></script>
    
<!-- base href="http://www.hanselman.com/blog/" -->
<link rel="alternate" type="application/rss+xml" title="Scott Hanselman" href="http://www.hanselman.com/blog/SyndicationService.asmx/GetRss">
<link rel="alternate" type="application/atom+xml" title="Scott Hanselman" href="http://www.hanselman.com/blog/SyndicationService.asmx/GetAtom">
<link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.hanselman.com/blog/EditService.asmx/GetRsd"><link rel="microsummary" type="application/x.microsummary+xml" href="http://www.hanselman.com/blog/Microsummary.ashx">
<link rel="canonical" href="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">
<meta name="description" content="Ints are easy. Strings are mostly easy. Dates? A nightmare. They always will be. There's different calendars, different formats. Did you know it's 2004 in the ...">
<meta name="keywords" content="ASP.NET,Javascript,Open Source">
<meta name="twitter:card" content="summary">
 <meta name="twitter:site" content="@shanselman">
<meta name="twitter:creator" content="@shanselman">
<meta name="twitter:title" content="On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API">
<meta name="twitter:description" content="Ints are easy. Strings are mostly easy. Dates? A nightmare. They always will be. There's different calendars, different ...">
<meta name="twitter:image" content="http://www.hanselman.com/blog/content/binary/Windows-Live-Writer/On-the-nightmare-that-is-JSON-Dates_D34C/image_8.png">
<meta name="og:url" content="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">
<meta name="og:title" content="On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API">
<meta name="og:image" content="http://www.hanselman.com/blog/content/binary/Windows-Live-Writer/On-the-nightmare-that-is-JSON-Dates_D34C/image_8.png">
<meta name="og:description" content="Ints are easy. Strings are mostly easy. Dates? A nightmare. They always will be. There's different calendars, different ...">
<meta name="og:type" content="blog">
<meta name="fb:admins" content="552706617">
<meta name="fb:app_id" content="552706617">
<script type="application/ld+json"> 
{
"@context": "http://schema.org","@type": "BlogPosting","headline": "On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API","datePublished": "2012-03-06","description": "Ints are easy. Strings are mostly easy. Dates? A nightmare. They always will be. There's different calendars, different formats. Did you know it's 2004 in the ... ...","url": "http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx","image": "http://www.hanselman.com/blog/content/binary/Windows-Live-Writer/On-the-nightmare-that-is-JSON-Dates_D34C/image_8.png"}
</script>
<style type="text/css">.ob-tcolor{color:rgb(51, 51, 51)} .ob-lcolor{color:rgb(226, 132, 44)} .ob-bgtcolor{background-color:rgb(51, 51, 51)} .item-link-container:hover .ob-tcolor{border-color:rgb(51, 51, 51)} </style><script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/a.js" async="" type="text/javascript"></script></head>

<body class="line-darkbrown"><form method="post" action="/blog/CommentView.aspx?title=OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI" id="mainForm">
<div class="aspNetHidden">
<input name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTM2MTcxNzAwMA9kFgJmD2QWAgIFD2QWAgIDD2QWAmYPDxYCHgdlbnRyeUlkBSQxYjcxMzY1MS0zYWQ0LTQxZTctOWQ4NS0zNTRmMjI3ZGRkNTdkFgJmD2QWCAIBDxYCHgdWaXNpYmxlZxYCAgEPDxYCHgRUZXh0BRRDb21tZW50cyBhcmUgY2xvc2VkLmRkAgIPFgIfAWgWAgIBDw8WAh8CBUtBbGwgY29tbWVudHMgcmVxdWlyZSB0aGUgYXBwcm92YWwgb2YgdGhlIHNpdGUgb3duZXIgYmVmb3JlIGJlaW5nIGRpc3BsYXllZC5kZAIDDxYCHwFoFgJmD2QWAmYPZBYEAgEPDxYCHwIFBk9wZW5JRGRkAgMPDxYEHhJFbmFibGVDbGllbnRTY3JpcHRoHgxFcnJvck1lc3NhZ2UFOVBsZWFzZSBlbnRlciB5b3VyIE9wZW5JZCBvciB5b3VyIE5hbWUsIEVtYWlsIGFuZCBXZWJwYWdlLmRkAgQPFgIfAWgWEGYPZBYCZg9kFgQCAQ8PFgIfAgUETmFtZWRkAgMPDxYCHwQFMVlvdSBtdXN0IGVudGVyIHlvdXIgbmFtZSAtIG9yIGF0IGxlYXN0IHNvbWUgbmFtZS5kZAIBD2QWBGYPZBYEAgEPDxYCHwIFBkUtbWFpbGRkAgMPDxYEHwNoHwQFSlRoZSBlLW1haWwgYWRkcmVzcyBpcyBvcHRpb25hbCwgYnV0IGlmIHlvdSBwcm92aWRlIGl0LCBpdCBzaG91bGQgYmUgdmFsaWQuZGQCAQ9kFgICAw9kFgICAQ8PFgIfAgVUKHdpbGwgc2hvdyB5b3VyIDxhIGhyZWY9Imh0dHA6Ly93d3cuZ3JhdmF0YXIuY29tIiB0YXJnZXQ9Il9ibGFuayI+Z3JhdmF0YXI8L2E+IGljb24pZGQCAg9kFgJmD2QWAgIBDw8WAh8CBQlIb21lIHBhZ2VkZAIDD2QWAmYPZBYCAgEPEA8WAh8CBQtSZW1lbWJlciBNZWRkZGQCBA9kFgJmD2QWBgIBDw8WAh4HRW5hYmxlZGhkZAICDw8WAh8EBRtQbGVhc2UgZW50ZXIgdGhlIGNvZGUgc2hvd25kZAIDDw8WBB8DaB8EBR5FbXB0eSBjb21tZW50cyBhcmVuJ3QgYWxsb3dlZC5kZAIFD2QWAmYPZBYEAgEPDxYEHwIFGkNvbW1lbnQgKEhUTUwgbm90IGFsbG93ZWQpHwFoZGQCAw8PFgIfAgX7AUNvbW1lbnQgKFNvbWUgaHRtbCBpcyBhbGxvd2VkOiA8Y29kZT5hQGhyZWZAdGl0bGUsIGIsIGJsb2NrcXVvdGVAY2l0ZSwgZW0sIGksIGxpLCBvbCwgcHJlLCBzdHJpa2UsIHN0cm9uZywgc3ViLCBzdXBlciwgdSwgdWw8L2NvZGU+KSB3aGVyZSB0aGUgQCBtZWFucyAiYXR0cmlidXRlLiIgRm9yIGV4YW1wbGUsIHlvdSBjYW4gdXNlICZsdDthIGhyZWY9IiIgdGl0bGU9IiImZ3Q7IG9yICZsdDtibG9ja3F1b3RlIGNpdGU9IlNjb3R0IiZndDsuZGQCBg9kFgJmD2QWAgIBDw8WAh8CBRRMaXZlIENvbW1lbnQgUHJldmlld2RkAggPZBYCZg9kFgICBw8PFgIfAgUMU2F2ZSBDb21tZW50ZGRkt5iMmK8+r6nQIKNUngzBpGQWV5k=" type="hidden">
</div>


				<script type="text/javascript">
					var allowedHtmlTags = ['a', 'b', 'blockquote', 'em', 'i', 'li', 'ol', 'pre', 'strike', 'strong', 'sub', 'super', 'u', 'ul'];
				</script>
				<script type="text/javascript" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/LiveCommentPreview.js" defer="defer"></script><script type="text/javascript" language="JavaScript">
<!--
function showReferral()
{
var elems = document.getElementsByTagName('*');
var count = 0;
for (var i=0;i<elems.length;i++) {
    if ( elems[i].id.indexOf('referralSpanHidden') != -1 ) {
        elems[i].style.display='inline';
        count++;
    }
    else if ( elems[i].id.indexOf('referralMore') != -1 ) {
        elems[i].style.display='none';
        count++;
    }
    if (count == 2) {break;}
}
}
// --></script>
<div class="aspNetHidden">

	<input name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="6BAEE71B" type="hidden">
</div>
<section class="containerOuter line-tan" id="topbar">
	<section class="containerInner">
    	<h1><a href="http://www.hanselman.com/">Scott Hanselman</a></h1>
        <nav>
        	<ul>
            	<li><a href="http://hanselman.com/about">about</a></li>
            	<li><a href="http://hanselman.com/blog" class="current">blog</a></li>
            	<li><a href="http://hanselman.com/speaking">speaking</a></li>
            	<li><a href="http://hanselman.com/podcasts">podcasts</a></li>
            	<li><a href="http://hanselman.com/books">books</a></li>  
          </ul>
        </nav>        
    </section>
</section>

<section class="containerOuter darkbrown searchBar">
	<section class="containerInner">
       <div class="searchBarNav">
              <div id="search">
                  <input id="searchString" placeholder="Learn to Tweet, Be a Better Developer, etc." onkeypress="if (event.keyCode == 13) {doSearch(searchString.value);return false;}" type="text">
                  <input id="searchButton" name="googleSearchName" value="Search" language="javascript" onclick="doSearch(searchString.value);return false;" type="button">
              </div>
              <div id="archives">
                browse by <a title="The complete archive of Scott's Blog" href="http://www.hanselman.com/blog/archives.aspx">category</a> or <a title="Scott's blog posts in a friendly calendar format" href="http://www.hanselman.com/blog/monthview.aspx">date</a>
              </div>
      </div>
    </section>
</section>



<main>
<div id="ctl01_content" class="bodyContentStyle">
    <!-- BEGIN ID SELECTOR -->

    <script type="text/javascript">
       idselector_input_id = 'ctl01_openid_identifier';
    </script>

    <script type="text/javascript" id="__openidselector" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openidselector.js" charset="utf-8"></script>

    <!-- END ID SELECTOR -->
    <div id="ctl01_commentViewContent">
    <a name="a1b713651-3ad4-41e7-9d85-354f227ddd57"></a><article>
<section class="containerOuter blogHeader line-chocolate">
	<section class="containerInnerNarrow">
    	<h2 class="blogTitle"><a class="TitleLinkStyle" rel="bookmark" href="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API</a></h2>
    </section>
</section>

<section class="containerOuter burntSienna blogMetaInfo">
	<section class="containerInnerNarrow">
		<span class="blogMetaDate">March 6, '12</span>
		<a class="commentLinkStyle" href="http://www.hanselman.com/blog/CommentView.aspx?guid=1b713651-3ad4-41e7-9d85-354f227ddd57#commentstart">Comments [69]</a>
    <span class="blogMetaCategories">Posted in <a class="categoryLinkStyle" href="http://www.hanselman.com/blog/CategoryView.aspx?category=ASP.NET">ASP.NET</a>&nbsp;|&nbsp;<a class="categoryLinkStyle" href="http://www.hanselman.com/blog/CategoryView.aspx?category=Javascript">Javascript</a>&nbsp;|&nbsp;<a class="categoryLinkStyle" href="http://www.hanselman.com/blog/CategoryView.aspx?category=Open+Source">Open Source</a></span>    
    </section>
</section>
<section class="containerOuter blogBodyContainer">
	<section class="containerInner blogBody">
          <div class="ad-item ad-sponsoreditem">
              Sponsored By<br>
                  <div id="lqdmad">
                   <!-- <div data-type="ad" class="lqm_ad" data-publisher="lqm.scotthanselman.site" data-zone="ron" data-format="125x125" data-tags="Mobile%2CHTML5%2CCSS%2CWeb%2CJavascript%2CAgile%2CCloud%2CHosting%2Cvs%2CASP.NET%2CWP7%2CWPF%2CXML%2CParallelism%2CEntity%20Framework%2CjQuery%2CMVC%2CAJAX"></div> -->
                    <div class="lqm_ad" data-type="ad" data-publisher="lqm.scotthanselman.site" data-zone="ron" data-format="160x600" data-tags="Mobile%2CHTML5%2CCSS%2CWeb%2CJavascript%2CAgile%2CCloud%2CHosting%2Cvs%2CASP.NET%2CWP7%2CWPF%2CXML%2CParallelism%2CEntity%20Framework%2CjQuery%2CMVC%2CAJAX"><iframe id="dmad1" allowtransparency="false" style="z-index:10" marginwidth="0" marginheight="0" scrolling="no" height="600" width="160" frameborder="0"></iframe></div>

                  </div>
         </div>
		<p>Ints are easy. Strings are mostly easy. Dates? A nightmare. They 
always will be. There's different calendars, different formats. Did you 
know it's 2004 in the Ethiopian Calendar? Yakatit 26, 2004, in fact. I 
spoke to a German friend once about how much 9/11 affected me and he 
said, "yes, <a href="http://en.wikipedia.org/wiki/Berlin_Wall#Demolition">November 9th</a> was an amazing day in Germany, also." </p>  <p>Dates are hard.</p>  <p>If I take a simple model:</p>  <div><div id="highlighter_927717" class="syntaxhighlighter  csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp keyword">public</code> <code class="csharp keyword">class</code> <code class="csharp plain">Post</code></div><div class="line number2 index1 alt1"><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp keyword">int</code> <code class="csharp plain">ID { </code><code class="csharp keyword">get</code><code class="csharp plain">; </code><code class="csharp keyword">set</code><code class="csharp plain">; }</code></div><div class="line number4 index3 alt1">&nbsp;</div><div class="line number5 index4 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">[StringLength(60)][Required]</code></div><div class="line number6 index5 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp keyword">string</code> <code class="csharp plain">Title { </code><code class="csharp keyword">get</code><code class="csharp plain">; </code><code class="csharp keyword">set</code><code class="csharp plain">; }</code></div><div class="line number7 index6 alt2">&nbsp;</div><div class="line number8 index7 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">[StringLength(500)]</code></div><div class="line number9 index8 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">[DataType(DataType.MultilineText)]</code></div><div class="line number10 index9 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">[AllowHtml]</code></div><div class="line number11 index10 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp keyword">string</code> <code class="csharp plain">Text { </code><code class="csharp keyword">get</code><code class="csharp plain">; </code><code class="csharp keyword">set</code><code class="csharp plain">; }</code></div><div class="line number12 index11 alt1">&nbsp;</div><div class="line number13 index12 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp plain">DateTime PublishedAt { </code><code class="csharp keyword">get</code><code class="csharp plain">; </code><code class="csharp keyword">set</code><code class="csharp plain">; }</code></div><div class="line number14 index13 alt1"><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div>

<p>And I make a quick ASP.NET Web API controller from VS11 Beta (snipped some stuff for simplicity):</p>

<div><div id="highlighter_981119" class="syntaxhighlighter  csharp"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="csharp keyword">public</code> <code class="csharp keyword">class</code> <code class="csharp plain">PostAPIController : ApiController</code></div><div class="line number2 index1 alt1"><code class="csharp plain">{</code></div><div class="line number3 index2 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">private</code> <code class="csharp plain">BlogContext db = </code><code class="csharp keyword">new</code> <code class="csharp plain">BlogContext();</code></div><div class="line number4 index3 alt1">&nbsp;</div><div class="line number5 index4 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp comments">// GET /api/post</code></div><div class="line number6 index5 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp plain">IEnumerable&lt;Post&gt; Get()</code></div><div class="line number7 index6 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">{</code></div><div class="line number8 index7 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">return</code> <code class="csharp plain">db.Posts.ToList();</code></div><div class="line number9 index8 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">}</code></div><div class="line number10 index9 alt1">&nbsp;</div><div class="line number11 index10 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp comments">// GET /api/post/5</code></div><div class="line number12 index11 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">public</code> <code class="csharp plain">Post Get(</code><code class="csharp keyword">int</code> <code class="csharp plain">id)</code></div><div class="line number13 index12 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">{</code></div><div class="line number14 index13 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">return</code> <code class="csharp plain">db.Posts.Where(p =&gt; p.ID == id).Single();</code></div><div class="line number15 index14 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">}</code></div><div class="line number16 index15 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">...snip...</code></div><div class="line number17 index16 alt2"><code class="csharp plain">}</code></div></div></td></tr></tbody></table></div></div>

<p>And hit /api/post with this <a href="http://knockoutjs.com/">Knockout View Model</a> and jQuery.</p>

<div><div id="highlighter_80140" class="syntaxhighlighter  js"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="js plain">$(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div><div class="line number2 index1 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">$(</code><code class="js string">"#getPosts"</code><code class="js plain">).click(</code><code class="js keyword">function</code> <code class="js plain">() {</code></div><div class="line number3 index2 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js comments">// We're using a Knockout model. This clears out the existing posts.</code></div><div class="line number4 index3 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">viewModel.posts([]);</code></div><div class="line number5 index4 alt2">&nbsp;</div><div class="line number6 index5 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">$.get('/api/PostAPI', </code><code class="js keyword">function</code> <code class="js plain">(data) {</code></div><div class="line number7 index6 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js comments">// Update the Knockout model (and thus the UI) </code></div><div class="line number8 index7 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js comments">// with the posts received back </code></div><div class="line number9 index8 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js comments">// from the Web API call.</code></div><div class="line number10 index9 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">viewModel.posts(data);</code></div><div class="line number11 index10 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">});</code></div><div class="line number12 index11 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">});</code></div><div class="line number13 index12 alt2">&nbsp;</div><div class="line number14 index13 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;</code><code class="js plain">viewModel = {</code></div><div class="line number15 index14 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">posts: ko.observableArray([])</code></div><div class="line number16 index15 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">};</code></div><div class="line number17 index16 alt2">&nbsp;</div><div class="line number18 index17 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;</code><code class="js plain">ko.applyBindings(viewModel);</code></div><div class="line number19 index18 alt2"><code class="js plain">});</code></div></div></td></tr></tbody></table></div></div>

<p>And this super basic template:</p>

<div><div id="highlighter_656739" class="syntaxhighlighter  xml"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="xml plain">&lt;</code><code class="xml keyword">li</code> <code class="xml color1">class</code><code class="xml plain">=</code><code class="xml string">"comment"</code><code class="xml plain">&gt;</code></div><div class="line number2 index1 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">header</code><code class="xml plain">&gt;</code></div><div class="line number3 index2 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">div</code> <code class="xml color1">class</code><code class="xml plain">=</code><code class="xml string">"info"</code><code class="xml plain">&gt;</code></div><div class="line number4 index3 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">strong</code><code class="xml plain">&gt;&lt;</code><code class="xml keyword">span</code> <code class="xml color1">data-bind</code><code class="xml plain">=</code><code class="xml string">"text: Title"</code><code class="xml plain">&gt;&lt;/</code><code class="xml keyword">span</code><code class="xml plain">&gt;&lt;/</code><code class="xml keyword">strong</code><code class="xml plain">&gt;</code></div><div class="line number5 index4 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;/</code><code class="xml keyword">div</code><code class="xml plain">&gt;</code></div><div class="line number6 index5 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;/</code><code class="xml keyword">header</code><code class="xml plain">&gt;</code></div><div class="line number7 index6 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">div</code> <code class="xml color1">class</code><code class="xml plain">=</code><code class="xml string">"body"</code><code class="xml plain">&gt;</code></div><div class="line number8 index7 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">p</code> <code class="xml color1">data-bind</code><code class="xml plain">=</code><code class="xml string">"date: PublishedAt"</code><code class="xml plain">&gt;&lt;/</code><code class="xml keyword">p</code><code class="xml plain">&gt;</code></div><div class="line number9 index8 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">p</code> <code class="xml color1">data-bind</code><code class="xml plain">=</code><code class="xml string">"text: Text"</code><code class="xml plain">&gt;&lt;/</code><code class="xml keyword">p</code><code class="xml plain">&gt;</code></div><div class="line number10 index9 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;/</code><code class="xml keyword">div</code><code class="xml plain">&gt;</code></div><div class="line number11 index10 alt2"><code class="xml plain">&lt;/</code><code class="xml keyword">li</code><code class="xml plain">&gt;</code></div></div></td></tr></tbody></table></div></div>

<p>I am saddened as the date binding doesn't work, because the date was 
serialized by default like this. Here's the JSON on the wire.</p>

<div><div id="highlighter_512463" class="syntaxhighlighter  js"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="js plain">[{</code></div><div class="line number2 index1 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"ID"</code><code class="js plain">: 1,</code></div><div class="line number3 index2 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"PublishedAt"</code><code class="js plain">: </code><code class="js string">"\/Date(1330848000000-0800)\/"</code><code class="js plain">,</code></div><div class="line number4 index3 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"Text"</code><code class="js plain">: </code><code class="js string">"Best blog post ever"</code><code class="js plain">,</code></div><div class="line number5 index4 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"Title"</code><code class="js plain">: </code><code class="js string">"Magical Title"</code></div><div class="line number6 index5 alt1"><code class="js plain">}, {</code></div><div class="line number7 index6 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"ID"</code><code class="js plain">: 2,</code></div><div class="line number8 index7 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"PublishedAt"</code><code class="js plain">: </code><code class="js string">"\/Date(1320825600000-0800)\/"</code><code class="js plain">,</code></div><div class="line number9 index8 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"Text"</code><code class="js plain">: </code><code class="js string">"No, really"</code><code class="js plain">,</code></div><div class="line number10 index9 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"Title"</code><code class="js plain">: </code><code class="js string">"You rock"</code></div><div class="line number11 index10 alt2"><code class="js plain">}]</code></div></div></td></tr></tbody></table></div></div>

<p>Eek! My eyes! That's milliseconds since the beginning of the Unix 
Epoch WITH a TimeZone. So, converting in PowerShell looks like:</p>

<pre>PS C:\&gt; (new-object DateTime(1970,1,1,0,0,0,0)).AddMilliseconds(1330848000000).AddHours(-8)<br><br>Sunday, March 04, 2012 12:00:00 AM</pre>

<p>Yuck. Regardless,&nbsp; it doesn't bind with KnockoutJS either. I <em>could </em>add a bindingHandler for dates like this:</p>

<div><div id="highlighter_890849" class="syntaxhighlighter  js"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="js plain">ko.bindingHandlers.date = {</code></div><div class="line number2 index1 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">init: </code><code class="js keyword">function</code> <code class="js plain">(element, valueAccessor, allBindingsAccessor, viewModel) {</code></div><div class="line number3 index2 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js keyword">var</code> <code class="js plain">jsonDate = valueAccessor();</code></div><div class="line number4 index3 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js keyword">var</code> <code class="js plain">value = </code><code class="js keyword">new</code> <code class="js plain">Date(parseInt(jsonDate.substr(6)));</code></div><div class="line number5 index4 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js keyword">var</code> <code class="js plain">ret = value.getMonth() + 1 + </code><code class="js string">"/"</code> <code class="js plain">+ value.getDate() + </code><code class="js string">"/"</code> <code class="js plain">+ value.getFullYear();</code></div><div class="line number6 index5 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">element.innerHTML = ret;</code></div><div class="line number7 index6 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">},</code></div><div class="line number8 index7 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">update: </code><code class="js keyword">function</code> <code class="js plain">(element, valueAccessor, allBindingsAccessor, viewModel) {</code></div><div class="line number9 index8 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">}</code></div><div class="line number10 index9 alt1"><code class="js plain">};</code></div></div></td></tr></tbody></table></div></div>

<p>That works, but it's horrible and I hate myself. It's lousy parsing 
and it doesn't even take the TimeZone into consideration. This is a 
silly format for a date to be in on the wire.</p>

<p><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="Example of Knockout binding" alt="Example of Knockout binding" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/image_8.png" border="0" height="256" width="187"></p>

<p>I was talking to some folks on Twitter in the last few days and said 
that all this is silly and JSON dates should be ISO 8601, and we should 
all move on. <a href="https://github.com/JamesNK/Newtonsoft.Json/commit/fd760e33898cc6b3badaf4a8b77a466139b87fac">James Newton-King the author of JSON.NET answered by making ISO 8601 the default in his library</a>. We on the web team will be including JSON.NET as the default JSON Serializer in Web API when it releases, so that'll be nice. </p>

<p>I mentioned this to Raffi from Twitter a few weeks back and he agreeds. He tweeted back to me</p>

<iframe title="Twitter Tweet" data-tweet-id="176096982144778240" style="position: static; visibility: visible; width: 500px; height: 302.8px; padding: 0px; border: medium none; min-width: 220px; max-width: 100%; margin-top: 10px; margin-bottom: 10px; display: block;" allowfullscreen="true" class="twitter-tweet twitter-tweet-rendered" allowtransparency="true" scrolling="no" id="twitter-widget-i1440144752155836556" frameborder="0"></iframe>

<p><script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/widgets.js" charset="utf-8"></script>He also added "please don't do what the <a href="https://twitter.com/#%21/twitterAPI"><s>@</s><b>twitterAPI</b></a> does (ruby strings)." What does that look like? Well, see for yourself: <a href="https://www.twitter.com/statuses/public_timeline.json">https://www.twitter.com/statuses/public_timeline.json</a> in a random public timeline tweet...snipped out the boring stuff...</p>

<div><div id="highlighter_574352" class="syntaxhighlighter  js"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="js plain">{</code></div><div class="line number2 index1 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"id_str"</code><code class="js plain">: </code><code class="js string">"176815815037952000"</code><code class="js plain">,</code></div><div class="line number3 index2 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"user"</code><code class="js plain">: {</code></div><div class="line number4 index3 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"id"</code><code class="js plain">: 455349633,</code></div><div class="line number5 index4 alt2"><code class="js plain">...snip...</code></div><div class="line number6 index5 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"time_zone"</code><code class="js plain">: </code><code class="js keyword">null</code></div><div class="line number7 index6 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js plain">},</code></div><div class="line number8 index7 alt1"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"id"</code><code class="js plain">: 176815815037952000,</code></div><div class="line number9 index8 alt2"><code class="js spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="js string">"created_at"</code><code class="js plain">: </code><code class="js string">"Mon Mar 05 23:45:50 +0000 2012"</code></div><div class="line number10 index9 alt1"><code class="js plain">}</code></div></div></td></tr></tbody></table></div></div>

<p>Yes, so DON'T do it that way. Let's just do it the JavaScript 
1.8.5/ECMASCript 5th way and stop talking about it. Here's Firefox, 
Chrome and IE.</p>

<p><a href="http://www.hanselman.com/blog/content/binary/Windows-Live-Writer/On-the-nightmare-that-is-JSON-Dates_D34C/image_4.png"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="All the browsers support toJSON()" alt="All the browsers support toJSON()" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/image_thumb_1.png" border="0" height="388" width="426"></a></p>

<p>We're going to do this by default in ASP.NET Web API when it releases. (We aren't doing this now in Beta) You can see <a href="http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx">how to swap out the serializer to JSON.NET on Henrik's blog</a>. You can also <a href="https://github.com/ChristianWeyer/Thinktecture.Web.Http">check out the Thinktecture.Web.Http convenience methods</a> that bundles some useful methods for ASP.NET Web API. </p>

<p>Today with the Beta, I just need to update my global.asax and swap 
out the JSON Formatter like this (see Henrik's blog for the full code):</p>

<div><div id="highlighter_523744" class="syntaxhighlighter  js"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="js comments">// Create Json.Net formatter serializing DateTime using the ISO 8601 format</code></div><div class="line number2 index1 alt1"><code class="js plain">JsonSerializerSettings serializerSettings = </code><code class="js keyword">new</code> <code class="js plain">JsonSerializerSettings();</code></div><div class="line number3 index2 alt2"><code class="js plain">serializerSettings.Converters.Add(</code><code class="js keyword">new</code> <code class="js plain">IsoDateTimeConverter());</code></div><div class="line number4 index3 alt1"><code class="js plain">GlobalConfiguration.Configuration.Formatters[0] = </code><code class="js keyword">new</code> <code class="js plain">JsonNetFormatter(serializerSettings);</code></div></div></td></tr></tbody></table></div></div>

<p>When we ship, none of this will be needed as it should be the default
 which is much nicer. JSON.NET will be the default serializer AND Web 
API will use ISO 8601 on the wire as the default date format for JSON 
APIs.</p>

<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="ISO Dates in Fiddler" alt="ISO Dates in Fiddler" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/image_7.png" border="0" height="195" width="266"></p>

<p>Hope this helps.</p>

<hr>

<p><strong>Sponsor:</strong> Big thanks to DevExpress for sponsoring this last week's feed. <em>There is no better time to discover DevExpress. Visual Studio 11 beta is here and DevExpress tools are ready! </em><a href="http://ad.doubleclick.net/clk;253980274;66891495;b?http://go.devexpress.com/betashrss.aspx"><em>Experience next generation tools, today</em></a><em>.</em></p>

<div class="item-prevnext">
    <a href="http://www.hanselman.com/blog/HowToGuideToInstallingAndBootingWindows8ConsumerPreviewOffAVHDVirtualHardDisk.aspx">«&nbsp;How To Guide to Installing and Booting W...</a> | <a href="http://www.hanselman.com/blog/default.aspx" rel="home">Blog Home</a> | <a href="http://www.hanselman.com/blog/DarkMatterDevelopersTheUnseen99.aspx">Dark Matter Developers: The Unseen 99%&nbsp;»</a>
</div>
  
		
<div class="about-scott">
	<div class="bioBox">
	    <h4>About Scott</h4>
        <div class="bioBoxInner">
			<p>Scott Hanselman is a former professor, former Chief Architect in 
finance, now speaker, consultant, father, diabetic, and Microsoft 
employee. He is a failed stand-up comic, a cornrower, and a book author.</p>
            <a href="http://facebook.com/scott.hanselman" class="sm-link"><img src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/icon-fb.png" alt="facebook"></a>
            <a href="http://twitter.com/shanselman" class="sm-link"><img src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/icon-twitter.png" alt="twitter"></a>
            <a href="http://plus.google.com/108573066018819777334?rel=author" class="sm-link" rel="author"><img src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/icon-gplus.png" alt="g+"></a>
            <a href="http://feeds.hanselman.com/ScottHanselman" class="sm-link"><img src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/icon-rss.png" alt="subscribe"></a><br>
            <a href="http://hanselman.com/about">About</a> &nbsp; <a href="http://www.hanselman.com/newsletter">Newsletter</a>
        </div>
	</div> 
    
      <div class="ads-box">
          <div class="ad-item ">
              <strong>Sponsored By</strong><br>
                  <div id="lqdmad">
                    <div data-type="ad" class="lqm_ad" data-publisher="lqm.scotthanselman.site" data-zone="ron" data-format="125x125" data-tags="Mobile%2CHTML5%2CCSS%2CWeb%2CJavascript%2CAgile%2CCloud%2CHosting%2Cvs%2CASP.NET%2CWP7%2CWPF%2CXML%2CParallelism%2CEntity%20Framework%2CjQuery%2CMVC%2CAJAX"><iframe id="dmad2" allowtransparency="false" style="z-index:10" marginwidth="0" marginheight="0" scrolling="no" height="125" width="125" frameborder="0"></iframe><div style="display: none; width: 125px; height: 125px; text-align: left; border-style: solid; border-width: 1px; position: relative; font: 14px/18px &quot;Segoe UI&quot;,Arial; background-color: white;"><input style="z-index: 1000; position: absolute; left: 0px; top: 0px; width: 14px; height: 14px;" title="Show Ad" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/redo.png" type="image"></div></div> 
                  </div>
         </div>
         <div class="ad-item">
              <strong>Hosting By</strong><br>
                <a rel="nofollow" href="http://www.orcsweb.com/"><img alt="Dedicated Windows Server Hosting by ORCS Web" class="ad" valign="top" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/Hanselman250x250.jpg" border="0" height="125" vspace="4" width="125"></a>
          </div>        

     </div>
</div>
  
  <div class="item-ads">
    <div class="lqm_ad" lqm_tags="Mobile%2CHTML5%2CCSS%2CWeb%2CJavascript%2CAgile%2CCloud%2CHosting%2Cvs%2CASP.NET%2CWP7%2CWPF%2CXML%2CParallelism%2CEntity%20Framework%2CjQuery%2CMVC%2CAJAX" lqm_publisher="lqm.scotthanselman.site" lqm_zone="RON" lqm_format="728x90"><iframe id="dmad3" allowtransparency="false" style="z-index:10" marginwidth="0" marginheight="0" scrolling="no" height="90" width="728" frameborder="0"></iframe></div>
  </div>
		

		<div style="display: none;" id="ob_holder"><iframe src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/comScore.htm" style="display: none; width: 1px; height: 1px;" id="ob_iframe"></iframe></div><div id="outbrain_widget_0" data-dynload="" data-os="win32" data-browser="firefox" data-ob-mark="true" obdone="true" data-src="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx" class="OUTBRAIN item-ads"><div class="ob_brnStrip_container NA">
    <span class="ob_empty"><wbr></span>
<style type="text/css">
.voterDiv .ob_bctrl{display:none;}
.ob_pdesc IMG{border:none;}
.NA .ob_what{direction:ltr;text-align:right;clear:both;padding:5px 10px 0px;}
.NA .ob_what a{color:#999;font-size:10px;font-family:arial;text-decoration: none;}
.NA .ob_what.ob-hover:hover a{text-decoration: underline;}
.NA .ob_clear{clear:both;}
.NA .ob_amelia,
.NA .ob_logo,
.NA .ob_text_logo
{display:inline-block;vertical-align:text-bottom;padding:0px 5px;box-sizing:content-box;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;}
.NA .ob_amelia{background:url('http://widgets.outbrain.com/images/widgetIcons/ob_logo_16x16.png') no-repeat center top;width:16px;height:16px;margin-bottom:-2px;}
.NA .ob_logo{background:url('http://widgets.outbrain.com/images/widgetIcons/ob_logo_67x12.png') no-repeat center top;width:67px;height:12px;}
.NA .ob_text_logo{background:url('http://widgets.outbrain.com/images/widgetIcons/ob_text_logo_66x23.png') no-repeat center top;width:66px;height:23px;}
.NA:hover .ob_amelia,
.NA:hover .ob_logo,
.NA:hover .ob_text_logo{background-position:center bottom;}
    .NA .ob_container{width:100%;position:relative;overflow:hidden;}
.NA .strip-img{width:109px;height:109px;border:none !important;margin:0px !important;display:block;padding:0px !important;}
.NA .item-link-container{text-decoration:none;}
.NA .strip-rec-link-title{font-size:13px;font-weight:normal;line-height:16px;}
.NA .strip-rec-link-source{font-size:12px;line-height:16px}
.NA .strip-like{padding-bottom:4px;font-size:14px;line-height:16px;height:20px;font-weight:bold;}
.NA .item-container a,.NA .item-container a:hover,.NA .item-container a:visited{border:medium none;text-decoration:none;}
.NA .ob_video{border:medium none;position:absolute;top:5px;left:5px}
.NA .ob-rec-link-img{position:relative;}
.NA .wbr:before {content: \"\200B\"}
.NA .ob_container_recs{width:100%;position:absolute;}
.NA .ob_container_recs A{display:inline;direction:ltr;text-align:left;}
.NA .ob-text-content A{width:100%;padding:0px 0px;}
.NA .ob-text-content{padding-top:6px;}
.NA .item-container A.ob-text-content{display:block;}
.NA .ob_container_recs .item-container{float:left;direction:ltr;width:111px;margin-bottom:300px;padding-right:9px;}
.NA .ob_container_recs .ob-last{padding-right:0px;}
.NA .ob_container_shadow_outer{position:static;width:100%;}
.NA .ob_container_shadow .item-container-shadow{position:static;overflow-x:hidden;width:0px;float:left;direction:ltr;}
.NA .ob_container_shadow .item-container{width:111px;visibility:hidden;float:left}
    .NA .ob_org_header,
.NA .ob_ads_header{float: left; font-size:1.1em; font-weight:600;  padding-bottom:3px;}
.OUTBRAIN{clear:both; padding-top:5px; padding-bottom:5px;}    </style>
<style type="text/css" class="ob-custom-css">

</style>
    <span class="ob_org_header">
You might also like
</span>        <div class="ob_container">
    <div class="ob_container_recs">
                        <a class="item-link-container ob-odd" href="http://www.hanselman.com/blog/SettingUpWindows10ForIoTOnYourRaspberryPi2.aspx" data-redirect="http://traffic.outbrain.com/network/redir?p=xqwpequjZVulmDUl71yJ6amecMFtKgioNIikzNaauvXytQirLNTS4qaFmc9jJhIhBFFW_6ThBhbJ0-610pbpNO1AGrF1exF04I-Il4HJlGhkZnnwabtTUq6XB151Ms6Cd86PN99eOG_kBm-XVNS21jeDhk79vOLHmwddDe-JueurWHOKjQzlcgIG7m8ZYlaGos5BZr_ZkpyZ9OClDUBT3a9q7jvaq6HtVfH-rNNiBaiJvLHFuZvLRCmWMBMg5FI0PNmjgScbMviXMdMMrWewpfZ7i1H4Ax1d-MEwtU3sGd8zivBusHIH2lY7bVVhV5H_a1sCh3OKRjrE4mgrivdG9aIkemw8B6BKLoxoj3EzWz08AQVC284IsCy8YiuadAkSsZSdlJRABiEgN_Z1qPbGsSDTx91Zjju-XcVm18o6COYaBkpblhhY9Iap9-ysEkY8mAI86NWauphu8g6WXu1EGAaGfzgcv1nLN6gtwvCxmNjQieQqEqXy9ds9zvpGDtLZ&amp;c=4c5d8a57&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_self" rel="">
    <div class="item-container ob-recIdx-0     ob-o">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman" class="strip-img" alt="Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/15KwCt-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>                        </div>
</a>                    <a class="item-link-container ob-even" href="http://www.hanselman.com/blog/OmniSharpMakingCrossplatformNETARealityAndAPleasure.aspx" data-redirect="http://traffic.outbrain.com/network/redir?p=E0hnHbVe7sfvT7IXYAd0TyVXDxM13kq7LdPSkhBcWciZaR9stnd-FFEfQP9Xh8NIEvx3SEQbR8w3o0JLCvazbqrzT7fmte1Tz2pAeMrXLaV9AmVDJPLfoU0SBXWFj2_B--lX_HkEGCjv7PU5bVZhks-5Svt4ieNvV9KW7ReELLfKFffm-bYhiYzUQJMEARlDH4yy5eHaon_Q5jTIivS06rXIG1tnfnxGfD7M2pi0-3iaq28cxvxupa-dVbgWYoPxDAvDPFVEOEIQzR6FTSVf5XSKiwTRkNHdX9aR6jzGpcaCdLeU4NCqKxWLwAV4sw1XCCUgL5PGJHUKc2A7oGUFwBYQ8PrWzyL536nZlJjRC6TPy_P3pvVQnKZPpJPpOw3hw5qTolISH8zVHMkUH7H-WROj18uRISwptowpnyD2J108PMY7gi7MYPTcI1AAiK5zSBjm6_HeY5B2f9TK3FMfnh3Ws4Q8__o4fpHKLDt9o6L4BNM319hMX7pDPhjmoobe&amp;c=dac61e08&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_self" rel="">
    <div class="item-container ob-recIdx-1     ob-o">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman" class="strip-img" alt="OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/xdHyo-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>                        </div>
</a>                    <a class="item-link-container ob-odd" href="http://www.hanselman.com/blog/SixEssentialLanguageAgnosticProgrammingBooks.aspx" data-redirect="http://traffic.outbrain.com/network/redir?p=wFDOmTB0WWzBbC5gOqPsVtfoa9EMmR84AYc1eEIeoXl1mx8AkobVxOtWL7wP5nIPrbb3kKWQYM9utpqoCTz9WhIWjllyId0uxq95OI6M0tkBxZrnPkKx0L_xwsldU7CVLHxptW4EL5FRNp648Qaa6V5lCsiPprLmH4ZaYqCqmzwfXOZDYuYwPtGGFc7AKv1vNjpeWuv0plHYxDtsYy_BQhIGARbtsSSBtAbU4qe8dzaLcTvhNSupEmchbryLLQlEvwO8MC29ic_pSMIoHmNmN6Kd8RYmBJsp4Di_oQ9XRfgDYeXVQ6_KLZ2I1MIwtPIdTbv9RjBgHM2XzonCM3Fm3O6I09tsycyYiNuSARwgm_Z4n8g9M0bQS1HOKKB_zOmlel_MXhTCXzc6fmPqTRR8pUEDVJadilLV8YqrJfoQ8eeLg1n6LgK4EBe9mW_Ie6VsTaT__Ugh4B-LICCN4F2AyP9Qqwc2-ZAZkV8Y-C9lE_3Imt5mkN40MHCRwcvujoHo&amp;c=ff1d0932&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_self" rel="">
    <div class="item-container ob-recIdx-2     ob-o">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Six Essential Language Agnostic Programming Books - Scott Hanselman" class="strip-img" alt="Six Essential Language Agnostic Programming Books - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/an1YD-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Six Essential Language Agnostic Programming Books - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>                        </div>
</a>                    <a class="item-link-container ob-even" href="http://www.hanselman.com/blog/AptGetForWindowsOneGetAndChocolateyOnWindows10.aspx" data-redirect="http://traffic.outbrain.com/network/redir?p=rp2cIBjw6gfJjh7Yn4TY6WmvLb_5eo49PdzHnO5CjnPtCh49ahe_BMw0vQ81LJ9HuLXhugiMgA3a0ZaQM95BHGzBLp631rXP2TBjJnMGgS3f_XJqZXu7R1R7VkRQCv9pycBVHCpZbZS_euUErXbdEuzrrdx0eYgmTsf4bEw-ltdjlAJuhs-cVIte4brrNduTGKVqgxwtQJ-LHhChbbiMwbFfmMG351V7gn1kBe8IU6D5ynaJkaj5QYMVONRGJnAycXVD8ZqY5kSZwBleYY5gbGnw-pSss4zhGhpJK1oiy29r2c7XrQaQDZz8hzj94zPP83aaX_3AfsH_4AlKBE5fyRAyh2CWUc6HYgIfuJ6TVZf9vGmnLJIVkrP3c4MFbp7ZEIbq44YRNS_Hg70YwFKYQjqt2wjk_aS1ZMzsCu65SfbiEO0DaNeDhl5LvcE0PMAPKpxGMe3imzm4YRf1BE6qt0j0msq_ovqKbLA48QO5YBU7a3V52kGZ4AL80lexfUdG&amp;c=10ee7322&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_self" rel="">
    <div class="item-container ob-recIdx-3     ob-o">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman" class="strip-img" alt="Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/1AHEss-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>                        </div>
</a>                    <a class="item-link-container ob-odd" href="http://www.hanselman.com/blog/TwoMustHaveToolsForAMoreReadableWeb.aspx" data-redirect="http://traffic.outbrain.com/network/redir?p=8kIHuEwNWb8g0MyE3t6ecKL0wIKEpLLzWvGMK3foH_FcwoaMxiOt3kafb8L37kC6SkogTU9BNDG6Y9UigiS1kdFJPohu1FaXgXV-N7thOCNv2H3VtKZuvnFD5Mb2A1C6Fxilak9FuOf64FY4SJc4L-RwjU1JWeQvyk6nid7VHz76htDCQmkun7TZAn7TB9gwRNAy9P7q-UFCNO3HbYb-7vl2Cauz6O4Rg7JdaUVUgsixPv0mvhYv1RAeAf-m2sWYEHo0Yd4jjXXC2NPTTlQH9PtppZbIko85_JQ51Gxdq1z3EDz1_pvUnS1gux2c8447f9LWf7nvxkr3xwT7EAgjvvkRVHAiJvqSZ12KroP0iZZQIkjLDqfx7ABkiry_gXwbg0sEcbe2MABsS-YQ_PqkOdknlJdhq4EARKSWu_2Qc8a4eotZO-JRJbMtsy80Oa7cmawEbtpTICUFwecHT0Vqfo3aOfexm1gPk-kEauMpEz7B6tnxfMsxuehMoIDd-1pm&amp;c=3421ce7f&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_self" rel="">
    <div class="item-container ob-recIdx-4     ob-o">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Two Must-Have Tools for a More Readable Web - Scott Hanselman" class="strip-img" alt="Two Must-Have Tools for a More Readable Web - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/amVP0-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Two Must-Have Tools for a More Readable Web - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>                        </div>
</a>                    <a class="item-link-container ob-even" href="http://www.top10bestwebsitebuilders.com/how-to-create-a-website/business/webcom-vs-godaddy?utm_source=outbrainNI&amp;utm_campaign=9594&amp;utm_medium=$origsrcid$&amp;a=9594&amp;ts=ob" data-redirect="http://paid.outbrain.com/network/redir?p=hhIHr74kHT_p1AnHsEGbCtCHu4GzCNfckSI_y_pfleoejjwfySgwrzqXacR5IWf8sCem6gG8hy6y9oX6GYNacozvpn2vymW3Qn-TIT-kM63G10ZuvunYSAeza0HU11BdHCkYrx_o8RBkXCMas4wuZgA6wSf66tmILySY3qnmPN0W2PmGVMs10pL79Z1I_6hshTnUyOjZgk5d4qBDGonaXcIaKD2Mit2mTV8DryLhFKsw6iYiBi6PWYcQgAvN44z5bABjXUJpaGvWPhf6F2sgfDUjaEWxV1fwsEE-NvHBVmuhKZPgGS71FFy2H07x1n8wxyHwe4xjsSxW9hDjldlGo2Q9avrTvfxzbQoDTLjqzPwkV8VTRCCVN_nVkC_t5XQTDDFMiEOVg2KNwzz1sM3ViHiH6yJMi-wXyV9KbEwmtjKIawOCBhkWC9dYP7SGiNiZwWigOFW5AjIRQxU2GbRMsJMiBIMnyzwJOWlI1W22ysI2Vvfgo0QLZ-A2pkLnHYeUZlST2ZUG5HoFwbqKe2ox1hT33BW3y4XPPFVq2MDLZbwb9vy4m_LCzUuie3QLWgo3r7H5yiN6bA0BdAPQaejZrQ&amp;c=37d15b5c&amp;v=3" onclick="" onmousedown="outbrain.recClicked(event,this);" target="_blank" rel="nofollow">
    <div class="item-container ob-recIdx-5  item-container-ad  ob-last   ob-p">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="3 Best Sites to Build your own Website" class="strip-img" alt="3 Best Sites to Build your own Website" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/10dol0-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
                    </div>
	<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">3 Best Sites to Build your own Website</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"> <span class="rec-src-link"> (<span class="rec-src-at"></span>Website Builders)</span></span>    </div>
    </div>                        </div>
</a>            </div>
<div class="ob_container_shadow_outer">
    <div class="ob_container_shadow">
                                    <div class="item-container-shadow ob-recIdx-0   ob-odd">
    <div class="item-container ob-recIdx-0   ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman" class="strip-img" alt="Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/15KwCt-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Setting up Windows 10 for IoT on your Raspberry Pi 2 - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>    </div>
</div>                            <div class="item-container-shadow ob-recIdx-1  ob-even">
    <div class="item-container ob-recIdx-1   ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman" class="strip-img" alt="OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/xdHyo-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">OmniSharp - Making cross-platform .NET a reality, and a pleasure - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>    </div>
</div>                            <div class="item-container-shadow ob-recIdx-2   ob-odd">
    <div class="item-container ob-recIdx-2   ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Six Essential Language Agnostic Programming Books - Scott Hanselman" class="strip-img" alt="Six Essential Language Agnostic Programming Books - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/an1YD-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Six Essential Language Agnostic Programming Books - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>    </div>
</div>                            <div class="item-container-shadow ob-recIdx-3  ob-even">
    <div class="item-container ob-recIdx-3   ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman" class="strip-img" alt="Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/1AHEss-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Apt-Get for Windows - OneGet and Chocolatey on Windows 10 - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>    </div>
</div>                            <div class="item-container-shadow ob-recIdx-4   ob-odd">
    <div class="item-container ob-recIdx-4   ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="Two Must-Have Tools for a More Readable Web - Scott Hanselman" class="strip-img" alt="Two Must-Have Tools for a More Readable Web - Scott Hanselman" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/amVP0-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">Two Must-Have Tools for a More Readable Web - Scott Hanselman</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"></span>    </div>
    </div>    </div>
</div>                            <div class="item-container-shadow ob-recIdx-5  ob-even">
    <div class="item-container ob-recIdx-5  item-container-ad  ob-last ">
        <div class="ob-rec-link-img ob-tcolor">
    <img style="" onload="this.style.visibility=''" title="3 Best Sites to Build your own Website" class="strip-img" alt="3 Best Sites to Build your own Website" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/10dol0-SNp-109x109.jpg" onerror="outbrain.imageError(this)" height="109" width="109">
        </div>
	<div class="ob-text-content">
            <div class="strip-rec-link-title ob-tcolor">3 Best Sites to Build your own Website</div>
        <div class="strip-rec-link-source ob-lcolor">
        <span class="ob_source"> <span class="rec-src-link"> (<span class="rec-src-at"></span>Website Builders)</span></span>    </div>
    </div>    </div>
</div>                        </div>
</div>    </div>
            <div class="ob_what">
	
	<a href="#" onmousedown="" onclick="OBR.extern.callWhatIs('http://www.outbrain.com/what-is/default/en','',-1,-1,true ,null);return false">
		Recommended by<span class="ob_amelia" title="Outbrain"></span>
	</a>
</div>
    </div></div>
<script type="text/javascript">(function(){window.OB_platformType=8;window.OB_langJS="http://widgets.outbrain.com/lang_en.js";window.OBITm="1370325657162";window.OB_recMode="brn_strip";var ob=document.createElement("script");ob.type="text/javascript";ob.async=true;ob.src="http"+("https:"===document.location.protocol?"s":"")+"://widgets.outbrain.com/outbrainLT.js";var h=document.getElementsByTagName("script")[0];h.parentNode.insertBefore(ob,h);})();</script>

		<div class="item-footer">
   	      <a class="commentLinkStyle" href="http://www.hanselman.com/blog/CommentView.aspx?guid=1b713651-3ad4-41e7-9d85-354f227ddd57#commentstart">Comments [69]</a>
        <div class="item-footer-tools">
        
        
          Share on: <a href="http://twitter.com/intent/tweet?url=http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx&amp;text=On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman&amp;via=shanselman">Twitter</a>, <a href="http://facebook.com/sharer.php?u=http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">Facebook</a>, <a href="https://plus.google.com/share?url=http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx">Google+</a> or use the 
        
          <a href="http://www.hanselman.com/blog/OnTheNightmareThatIsJSONDatesPlusJSONNETAndASPNETWebAPI.aspx" class="permalink" rel="bookmark">Permalink</a>
        </div>    
    </div>
		
		
		
		
  </section>
</section>
</article>
<div id="endOfPost"></div><a name="commentstart"></a><div class="commentBoxStyle"><div class="commentDateStyle"><a name="537d42f4-84f3-4a93-9514-81b5175f8d80"></a>Tuesday, March 06, 2012 12:21:02 AM UTC</div><div class="commentBodyStyle">hmmm, my 1-liner to parse WCF JSON Dates :)<br><br><blockquote>function date(s) { return new Date(parseFloat(/Date\(([^)]+)\)/.exec(s)[1])); }<br></blockquote><br><br>Taken from my JSON prettifier: http://www.ajaxstack.com/jsonreport/</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_014.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlUePUpnmujqmls7kwVyPDG3G77dPRdZtM"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Demis Bellot</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="0b8787b3-f523-4497-b704-558a9f266357"></a>Tuesday, March 06, 2012 12:24:01 AM UTC</div><div class="commentBodyStyle">Boy
 am I glad I saw this post! I just put together a simple (or so I 
thought) app to try this out and was about to google the goofy date that
 was returned. You just saved me a lot of time and effort!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_004.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlTAXu9eT5VzcbC5NkjVQpmfWyKt5n_5Ic"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Eric Miller</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="5723ab39-ba59-489b-838d-6c20b542d554"></a>Tuesday, March 06, 2012 12:25:43 AM UTC</div><div class="commentBodyStyle">Actually crap:<br><br>new Date(parseInt(jsonDate.substr(6)));<br><br>Is much nicer, surprised that works... testing...</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_014.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlUePUpnmujqmls7kwVyPDG3G77dPRdZtM"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Demis Bellot</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="30eafd08-641a-4e08-a226-f7ce2a5efd65"></a>Tuesday, March 06, 2012 12:27:24 AM UTC</div><div class="commentBodyStyle">Great job, Scott.  That's the one thing about JSON that I could just never understand how it got that way...</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_006.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://www.product4me.com/">PRMan</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e4d56736-9942-44e9-b733-26b3c763290a"></a>Tuesday, March 06, 2012 12:29:56 AM UTC</div><div class="commentBodyStyle">@PRMan this provides a good explanation of why JSON dates are the way they are:<br><br>http://msdn.microsoft.com/en-us/library/bb299886.aspx<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_014.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlUePUpnmujqmls7kwVyPDG3G77dPRdZtM"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Demis Bellot</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="8e83ce49-6eec-45d3-94f9-f497f33979e8"></a>Tuesday, March 06, 2012 12:31:36 AM UTC</div><div class="commentBodyStyle">Ironically, the posting date for this entry says this hasn't happened for another eight hours.<br><br>"March 6, 2012 12:15 AM"<br><br>UTC conversion issue? :P</div><div class="commentBoxFooterStyle"><span class="commentPermalinkStyle">Kevin Clayborn</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="fe4ff4f7-ce9d-4fc1-ba57-1aabf50dc887"></a>Tuesday, March 06, 2012 12:34:03 AM UTC</div><div class="commentBodyStyle">Dates are such a common data type that it seems absurd that JSON didn't bother including this in the <a href="http://www.json.org/">standard</a>.<br><br><blockquote cite="http://www.json.org">"A
 value can be a string in double quotes, or a number, or true or false 
or null, or an object or an array. These structures can be nested." <a href="http://www.json.org/">JSON.org</a></blockquote><br><br>The latest version of <a href="http://sugarjs.com/">Sugar</a>
 handles the ugly date format from the default ASP.Net JSON serializer, 
but I really like using a standard date format, especially 8601. 
Hopefully all the JSON libraries will recognize this format. </div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_011.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawk2XocXKKUPJCqIHG_S2ciMc1mbm3K-mys"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Brian Brewder</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="845325e2-eb0d-4e5b-8d4f-32968efa99e6"></a>Tuesday, March 06, 2012 12:39:35 AM UTC</div><div class="commentBodyStyle">So, you are introducing a BREAKING CHANGE with this.  Just GREAT!!!  <br><br>I know you may hate the existing datetime format (I do to), but existing sites really rely on that, and this artical on MSDN <a href="http://msdn.microsoft.com/en-us/library/bb412170.aspx">Stand-Alone JSON Serialization</a>.<br><br>Basically, I can't just update to use this instead of the existing api for a few reasons:<br>1) Breaking the contract - We have told our users that the date has to be in this format<br>2)
 We have a strict restriction on using 3rd party libraries, so now you 
are DEFAULTING to it?? Our legal department will have a fit!<br>3) This 
also means you won't be using the DataContractJsonSeralizer anymore?  
What about WCF?  Is it also switching, or do we have issues within our 
own app (WCF expecting one format, and this giving another).<br><br>PLEASE
 DO NOT set JSON.NET as the default, but make it available, and fix the 
DataContractJsonSerializer to support more date formats than the 
\/Date(xxx)\/ one.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_009.png"></span><span class="commentPermalinkStyle">Chad</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="b799791e-f483-4b22-b69d-1557a0f66b3d"></a>Tuesday, March 06, 2012 12:45:27 AM UTC</div><div class="commentBodyStyle">This is lousy:<br><br>new Date(parseInt(jsonDate.substr(6)));<br><br>Don't do this, you are losing your timezone information.<br><br>Instead, just remove the \\ and / from the ASPNET string:<br><br>"\\/Date(1320825600000-0800)\\/".replace( /[\\/]/g, "")<br><br>This gives you:<br><br>Date(1320825600000-0800)<br><br>To convert this back into a JSON date, you can "new" the object in an eval:<br><br>var d = eval ("new " + "\\/Date(1320825600000-0800)\\/".replace( /[\\/]/g, ""))<br><br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_017.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawn6D10S3F3_fkFSWyZkFp4qE0KVC7yc_ws"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">John Liu</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="b0e0710b-303e-4141-9a7d-765a6870df85"></a>Tuesday, March 06, 2012 12:50:12 AM UTC</div><div class="commentBodyStyle">Great news! Sometimes standards really do make things easier, this one especially. Newton-King's JSON.Net really kicks butt too.<br><br>Also,
 I just finally setup a W8 box and played a little with VS11 Beta and 
the WebAPI. The OS experience is a little disheartening yet, but I'm 
digging VS and WebAPI a lot... anxious to work with it more.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_007.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmmlAnM4T1sPNPY_OX1Qei3dN_lPf8iGXM"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Trey White</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="d3ebbf6e-7d44-43de-bcad-9de838eab019"></a>Tuesday, March 06, 2012 12:51:14 AM UTC</div><div class="commentBodyStyle">Although
 the default date format of Json.NET is changing in Json.NET 4.5 (the 
next major release), there is a an option to continue using the 
Microsoft format.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_025.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://james.newtonking.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">James Newton-King</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="7bec5425-b903-4ff6-b96e-ff008df3cbbd"></a>Tuesday, March 06, 2012 1:03:22 AM UTC</div><div class="commentBodyStyle">My
 concern is the same.  If I just upgrade, without making any code 
changes, it will change the format.  This release was SUPPOSED to be an 
inline update that DID NOT have any breaking changes - THIS IS ONE.<br><br>And
 then, what about, like us, a large corp that can't update everything at
 once, we have some using the old and some using the new format.<br><br>This
 means, even if we could get by our legal department (they look really 
hard at the license agreement) that we can NEVER use the new format, as 
it won't work with the systems that still require the old, unless they 
update DataContractJsonSerializer with support for more dates.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_009.png"></span><span class="commentPermalinkStyle">Chad</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e8284311-ae8d-4d6e-9b85-b4a42b9b22fc"></a>Tuesday, March 06, 2012 1:22:23 AM UTC</div><div class="commentBodyStyle">Normal WCF JSON serialization isn't changing, and Web API is still in beta.<br><br>If
 you want to continue using DataContractJsonSerializer then why not 
create a MediaTypeFormatter that uses DataContractJsonSerializer? If 
Microsoft doesn't include one out of the box then I'm sure someone else 
will make one.<br><br>On licensing, Json.NET is the standard MIT license.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_025.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://james.newtonking.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">James Newton-King</a></div></div><div class="commentBoxStyle commentBoxAuthorStyle"><div class="commentDateStyle"><a name="dadd1499-706d-4fac-bf49-33c4b3572d84"></a>Tuesday, March 06, 2012 1:22:39 AM UTC</div><div class="commentBodyStyle commentBodyAuthorStyle">Chad
 - You don't use modernizr, Jquery, jqueryUI or any of the other 3rd 
party libs? This will be supported Open Source just like our existing 
uses I open source. Want to use a different default? Easy to switch 
back. Remember that when we include open source, we back it with 
support. If you call and have a problem with ASP.NET, we will support 
all of it, including the open source we ship. Does that help? We have 
been doing that for 3+ years now.<br><br>Also, Chad - we are changing 
only ASP.NET Web API...A product that isn't released. We aren't changing
 asp.net proper or WCF. Better? There is no breaking change as this is a
 new product, only now in beta.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_013.png"></span><span class="commentPermalinkStyle">Scott Hanselman</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="fabea423-6424-4a6d-9498-f1a8af6d8f3a"></a>Tuesday, March 06, 2012 1:28:28 AM UTC</div><div class="commentBodyStyle">Presumably,
 only code that is using the new Web API framework will be using the new
 JSON.NET and therefore the updated date format. <br><br>All of your old code is most likely fine as it wasn't written to target the ApiController.<br><br>I don't see how this is a breaking change.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_004.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://notebookheavy.com/">Ken Stone</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="a5bd0eaf-ba1b-40a7-b932-019a3ff48474"></a>Tuesday, March 06, 2012 1:34:34 AM UTC</div><div class="commentBodyStyle">@Chad,<br><br>I don't think you read the post correctly.  This change to the default serializer is happening in the <b>ASP.NET Web API</b>,
 not .NET.  The standalone serializer isn't being removed.  This change 
is only happening between the Web API beta and the final RTM.  If your 
corporation is as large as you say it is, I seriously doubt you have 
production code deployed on a Web API beta that was only released a 
couple weeks ago.<br><br>TLDR: Nobody moved your cheese.  Everything will be okay.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_008.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://geeksharp.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Scott Anderson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="d35ad527-0ad2-47b5-a3d1-f682ca7a9206"></a>Tuesday, March 06, 2012 1:41:29 AM UTC</div><div class="commentBodyStyle">OK, so now only the webapi is updated, that is better, but we still won't be able to use it.<br><br>I was more making a point about the library (as we already use JSON.NET in some situations.<br><br>The
 problem I see now is one of incompatibility.  If you aren't updating 
WCF, or ASP.NET, dates creating in one won't work in the other.  So how 
do you suggest calling an existing service when you have a DateTime as a
 property in the serialized object?  How do you know what format to put 
it in?<br><br>I know that JSON.NET can handle it, but it requires a 
special date handler, and DataContractJsonSerializer won't handle the 
new format.  Can there at least be updates to make it EASILY work 
between services, without having to know what date format it is in.<br><br>DateTime.Parse
 handles several, but not the existing DataContractJsonSerailizer 
format, and then there is JavascriptSerializer - which is different.<br><br>I really like the simplicity of the DataContractJsonSerializer, and have heard several of my coworkers complain about JSON.NET.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_009.png"></span><span class="commentPermalinkStyle">Chad</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="4f75d6ef-524c-4091-988f-0750c799b88d"></a>Tuesday, March 06, 2012 1:45:18 AM UTC</div><div class="commentBodyStyle">@Chad,<br><br>In
 those cases, you can force JSON.NET to use the Microsoft form instead 
of the 8601 standard as pointed out by James in a comment above.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_008.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://geeksharp.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Scott Anderson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="f11bdea1-8531-4ded-9b3f-1884e7e59982"></a>Tuesday, March 06, 2012 1:45:19 AM UTC</div><div class="commentBodyStyle">'Bout
 time- all it takes is a decent critical mass of libraries doing it the 
same way to get a de facto standard. This has been biting me in the a*s 
for at least the last 5 years- I'll be more than happy to throw away all
 that conversion code I've been patching in at various layers.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_023.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://blog.rolpdog.com/">Matt Davis</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="311ce28f-d09d-4d25-afec-91b7d2d590a5"></a>Tuesday, March 06, 2012 1:45:53 AM UTC</div><div class="commentBodyStyle">Or you could override the default serializer in the Web API to use the same one you use everywhere else. (Sorry to double post!)</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_008.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://geeksharp.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Scott Anderson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="1e9eceb3-c5b0-48e1-bd66-dd280cc56d53"></a>Tuesday, March 06, 2012 2:01:35 AM UTC</div><div class="commentBodyStyle">Sure,
 we could, but again, can't we make all of the MS serializers 
consistant, or at least deserialize both the existing format and 8601 
standard?</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_009.png"></span><span class="commentPermalinkStyle">Chad</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="c0475806-bca8-444e-9ed6-dc1008320a87"></a>Tuesday, March 06, 2012 2:33:57 AM UTC</div><div class="commentBodyStyle">How can I swap out for JSON.NET in all of ASP.NET?:<br>- JsonValueProvider for MVC model binding<br>- JsonResult from an MVC method<br>- Web API<br>- asmx services<br>- etc<br>Is there a voodoo initialize method(s) that says "just go do it for everything" I can call from Global.asax.cs?</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_015.png"></span><span class="commentPermalinkStyle">Rob</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="693028db-c735-42b3-ba77-b4fd1dd69d13"></a>Tuesday, March 06, 2012 2:46:45 AM UTC</div><div class="commentBodyStyle">So
 glad to see this!  I just recently ran into this issue with MVC3 
JsonResult.  Parsing it correctly client-side isn't the end of the 
world, but it's the little things that make all the difference.  I get 
more excited for VS2011 with the 4.5 Framework and all that's coming 
with them everyday.  Keep up the good work sir!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_010.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmsX16JTENxNtMsazWsBGjLde-85e6PIg8"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Alexander Kahoun</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="c4c334e0-30b3-42f6-a5fb-866caf842ea4"></a>Tuesday, March 06, 2012 2:51:23 AM UTC</div><div class="commentBodyStyle">yes, it's a good feature. the format "\/Date(1320825600000-0800)\/" is weird.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_011.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmGULxSB-4ugP8emNzFQoy621qOUeQ3qVA"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Qijun Feng</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="114378f6-f371-4277-afef-7b6081622126"></a>Tuesday, March 06, 2012 3:11:10 AM UTC</div><div class="commentBodyStyle">This
 is beyond fantastic news. I've been on a couple of projects recently 
where we were using vanilla MVC as an API endpoint, and the first thing I
 did was write a model binder to use JSON.NET for all of our 
serialization needs (because of the way it handles dates and 
enumerations). So nice to see the wheel not be reinvented.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_026.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkgB8iFazksbidJ4vP8-g8hbCH6iNsz3Pk"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Jeff Putz</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e8bd3bfa-f090-424c-9e4a-c01ecb69c0d8"></a>Tuesday, March 06, 2012 7:26:11 AM UTC</div><div class="commentBodyStyle">regarding the whole "9-11" thing.<br><br>im
 from south africa and we write our dates normally in the dd-mm-yy 
format. it makes sense, it goes from smallest, to biggest. i have never 
understood mm-dd-yy. please explain the logic behind it.. first list the
 medium one, then the small one, then the big one.<br><br>/weirdos<br><br><br><br><br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_022.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmgC1J8e5mpdTukKndHh_n52hUMMCO8MiA"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">hilton smith</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="ee47f749-1d39-4ae8-8162-aece7e3fa3c5"></a>Tuesday, March 06, 2012 7:44:53 AM UTC</div><div class="commentBodyStyle">I prefer to add one property to model<br><br>//your model<br>public DateTime PublishedAt { get; set; }<br><br>//new property<br>public string PublishedAtString { get{ return PublishedAt.ToShortDateString(); }}<br><br>This will display normal in view when passed with knockout and you won't  have any problems passing it to controller on POST.<br><br>Hope it helps.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_003.png"></span><span class="commentPermalinkStyle">Mata</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="6330adac-a547-4e43-9e0d-e72665e907f7"></a>Tuesday, March 06, 2012 8:19:57 AM UTC</div><div class="commentBodyStyle">I
 was just about to start solving this problem for my own project. My 
idea was to use the JavascriptSerializer as Shawn Wildermuth wrote: 
http://wildermuth.com/2012/2/22/WebAPI_for_the_MVC_Guy. But now I know 
the direction of WebApi I will follow that and use the approach of 
Henrik Nielsen and mark my code immediately as obsolete as soon as the 
next version of WebApi will arive ;-)<br>Thank for sharing this just in time!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_018.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmJfAtY06dO3wA9EMgWF6eokqVT_ViSLMA"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif"></a></div></div><div class="commentBoxStyle commentBoxAuthorStyle"><div class="commentDateStyle"><a name="59ce5643-3f5e-460b-953d-66014a50e0fe"></a>Tuesday, March 06, 2012 9:14:27 AM UTC</div><div class="commentBodyStyle commentBodyAuthorStyle">Mata - But ToShortDateString is culture sensitive and will serialize with the current culture of the thread.&nbsp;</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_013.png"></span><span class="commentPermalinkStyle">Scott Hanselman</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="46fbff50-d301-4642-9ea4-85616d2e1445"></a>Tuesday, March 06, 2012 9:55:21 AM UTC</div><div class="commentBodyStyle">Just wanted to say: Absolutely brilliant, very glad this is happening.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_002.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlqMHe68yDzFyB7Ky67M830sbWLujnmUk0"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Rik Hemsley</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="536cb4e8-9468-4ac2-bdcd-0847f82236b3"></a>Tuesday, March 06, 2012 10:25:58 AM UTC</div><div class="commentBodyStyle">@Scott
 I know, i'm looking forward to JSON.NET as the default JSON Serializer 
in Web API too, i just wanted to share my solution when you don't need 
globalization support (wire format to be culture-neutral). I use this 
approach and  set jqueryui datepicker to choose appropriate locale 
http://jqueryui.com/demos/datepicker/localization.html . It's not 
perfect but it works. <br><br>Regards, always a pleasure to read your blog.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_003.png"></span><span class="commentPermalinkStyle">Mata</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="787e4f1e-5bdc-4a42-8be6-c543d8d58214"></a>Tuesday, March 06, 2012 11:29:44 AM UTC</div><div class="commentBodyStyle">I completely agree with the adoption of ISO as a stringified date standard.  <br><br>Thinking
 I was clever I spent quite some time using the Unix Epoch / 1970 / what
 is this madness??!! style dates in my own applications.  In the end I 
came to the realisation that having something that can be read and 
understood by human eyes has real merit and so now I'm sticking with 
that.<br><br>Delighted to hear that this approach looks to be being adopted "officially".  Marvellous!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_008.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://icanmakethiswork.blogspot.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">icanmakethiswork.blogspot.com</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="9ff564e3-f3e6-4224-a8ab-c0ed86f8919b"></a>Tuesday, March 06, 2012 11:59:42 AM UTC</div><div class="commentBodyStyle">JsAction library has a solution too: http://jsaction.codeplex.com/wikipage?title=DateTime&amp;referringTitle=ExplainSource</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_021.jpg"></span><span class="commentPermalinkStyle">Vincenzo</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="ba80f953-c0d6-40ba-9535-5f79ca24f848"></a>Tuesday, March 06, 2012 1:14:31 PM UTC</div><div class="commentBodyStyle">Return a string and ToString the date with the correct DateTime format pattern.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_016.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlXqYHFsvtTNkNTHhV_MibTU6LUvxwnh64"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif"></a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="59fdee4b-1206-40e6-a10b-7f95fd747df7"></a>Tuesday, March 06, 2012 1:16:43 PM UTC</div><div class="commentBodyStyle">Fantastic news!  The very first thing I did when playing with the API was to swap in the JSON.NET formatter.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_010.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmvUhveUM9V8xnnTkK3tfRPixeBbPTLDF0"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Sean Gough</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="cd75310f-81d6-4c21-af42-ddbbda9d2a8a"></a>Tuesday, March 06, 2012 1:27:03 PM UTC</div><div class="commentBodyStyle">Please
 what ever you do, don't base it off Microsoft's broken format for 
IS8601.  
http://msdn.microsoft.com/en-us/library/system.globalization.datetimeformatinfo.sortabledatetimepattern.aspx<br><br>Please
 make sure that it comes out with millisecond resolution and nothing 
more, that the time zone is always included.  In cases of DateTime 
please use local machine timezone or UTC timezone of "Z".<br><br>This is how dates should be formatted from DateTime and DateTimeOffset.<br><br>"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z'"<br><br>I
 can't tell you how much it pains me to see all these different so 
called ISO formats in the .NET framework that don't really reflect 
reality.<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_013.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkGUVcSqzJIA9KYHRtxoJ0RcirG3gAEV6Q"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Nick Berardi</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="570367f3-b27a-4d26-8ee9-fae9c6554506"></a>Tuesday, March 06, 2012 1:28:32 PM UTC</div><div class="commentBodyStyle">Check
 out moment.js its a hardcore date parsing/formatting library and 
friendly to asp.net, I think you will find it solves most of the 
ugliness you mention in your post. cheers</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_009.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawmIp-ZvhKYHdjEHfJoMh3lnHNrBrdfPRas"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Pete Weissbrod</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e43ff060-36a3-4349-bceb-f087bfffc937"></a>Tuesday, March 06, 2012 1:46:45 PM UTC</div><div class="commentBodyStyle">To
 clarify my comment from above, the only DateTime formatter that follows
 ISO 8601 is "o".  But the industry as a whole, as pretty much settled 
on millisecond resolution for the DateTime format, mostly because this 
is the resolution of UNIX time.<br><br>It would be great if Microsoft also supported this.<br><br><pre>yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz (this is the "o" format, which is ISO 8601)<br>yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fff'Z' (this is the industry standard ISO 8601 format)</pre><br><br>It
 would save me a lot of time trying to create the most usable API across
 web clients, if Microsoft out of the box just supported this second 
format.<br><br>Thanks</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_013.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkGUVcSqzJIA9KYHRtxoJ0RcirG3gAEV6Q"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Nick Berardi</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="3a3ab5b0-705b-4e6a-9077-995aadf9c439"></a>Tuesday, March 06, 2012 1:56:23 PM UTC</div><div class="commentBodyStyle">This
 is great news!  As a middle tier developer working in the world of 
REST, this will make the interactions with the UI team just that much 
easier.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_005.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkP8hVIN2eF5Cv050oSvsSqOZkj3lzLTr0"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Eric Jones</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="fd3f37b6-f919-4063-94e7-fe2ac0c5caa1"></a>Tuesday, March 06, 2012 3:07:18 PM UTC</div><div class="commentBodyStyle">@hilton
 smith: It's because in US English we speak dates as, "March 5, 2012." 
So 3-5-12 makes sense. But what do we know... we still don't use the 
metric system.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_026.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkgB8iFazksbidJ4vP8-g8hbCH6iNsz3Pk"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Jeff Putz</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="88f6dcc4-26f1-4be2-86f0-bb5820e55a8a"></a>Tuesday, March 06, 2012 3:36:14 PM UTC</div><div class="commentBodyStyle">Thanks Scott! the choice of the dateTime format in JSON is really ugly!<br>I suffered from that nightmare, and decided finally to serialize in ISO 8601 as u did (Glad to do like U :)). but with cost!<br>Now if you tell me it's gonna be supported in future releases IT'LL BE GREAT!<br>I loved the "(new Date()).toJSON()" Part :)</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_008.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://islamath.myopenid.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">islamath.myopenid.com</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="9ee08e43-530d-4a52-ad9c-7c3f98a138a6"></a>Tuesday, March 06, 2012 5:46:34 PM UTC</div><div class="commentBodyStyle">Yes,
 dates are really hard.  The worst part is that most developers think 
that because its in the BCL that DateTime is perfect.  It's not.  There 
are a few guys trying to do something about it, by re-implementing 
java's "joda" project as pure .net.  Check out Jon Skeet's post about 
"Noda Time"  http://noda-time.blogspot.com<br><br>Also, 
DataContractJsonSerializer is pretty bad with JSON Dates.  It completely
 ignores the offset when deserializing, among other things.  
http://connect.microsoft.com/VisualStudio/feedback/details/723368<br><br>I'm
 super glad to head about JSON.Net being used for webapi instead.  
Question - is System.Json a different serializer than DCJS (in 
System.Runtime.Serialization)  If not, why the new namespace?</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_021.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlF9LNtzKgLz-e6W0hV5Dvy7hMHH2A9Klg"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Matt Johnson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="2b56b7fc-d73e-491c-b944-dfe94a5cde03"></a>Tuesday, March 06, 2012 9:07:58 PM UTC</div><div class="commentBodyStyle">@Nick Berardi<br><br>The Json.NET change to use ISO 8061 is available from GitHub now. Right now it follows how .NET writes ISO dates in XML.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_025.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://james.newtonking.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">James Newton-King</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e2d79006-f91d-4e28-bfcf-917810999a29"></a>Wednesday, March 07, 2012 1:54:52 PM UTC</div><div class="commentBodyStyle">Hi,<br><br>Great
 post, we actually bumped into similar issues not so long ago. As a 
consequence we actually coded our own JSON serailizer/deserializer a 
single and light yet powerful class named <i>JsonUtilities</i> which ends-up supporting three different date formats:<br> - \/Date(1330848000000-0800)\/, with or without “TZ“ (this is our default, and here's why: <a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx">http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx</a>)<br> - new Date(utc milliseconds)<br> - ISO 8601<br><br>Check-out this blog post if you want to know more: <a href="http://blog.codefluententities.com/2012/03/07/dates-and-json/">Dates and JSON</a><br><br>Cheers,<br>Carl</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_012.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawllhHRSeAaYEHB1ppCG_3EWQpFjaNbiLRU"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Carl Anderson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="02aa4cd4-e2cb-4efc-af97-d10f9e6c4253"></a>Wednesday, March 07, 2012 3:18:08 PM UTC</div><div class="commentBodyStyle">Dear Mr. Hanselman,<br><br>Are
 we going to see better odata support in Web API by the time it hits RTM
 especially for things like $inlinecount, etc that will make it possible
 to do paging and other stuff using it?<br><br>Thanks!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_024.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawn1_bfig2sy48XQmeRUgAZsC17Culi6hp8"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Vesselin Obreshkov</a></div></div><div class="commentBoxStyle commentBoxAuthorStyle"><div class="commentDateStyle"><a name="85d9e674-bfe5-48aa-96a0-198df3131fe5"></a>Thursday, March 08, 2012 12:47:16 AM UTC</div><div class="commentBodyStyle commentBodyAuthorStyle">Vesselin - If you want Web API to be like OData you are better off using OData, I think.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_013.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://www.hanselman.com/">Scott Hanselman</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="e5918198-c449-4d0d-9874-97f346fa009d"></a>Thursday, March 08, 2012 7:09:04 PM UTC</div><div class="commentBodyStyle">It
 seems that if we use this approach, that we are not allowed to have api
 controller methods that accept multiple parameters, or especially any 
parameters that are primitive types (int, string).  For example, if 
instead of taking a custom class instance as a parameter, my method 
takes two strings:<br><br>Post(string value1, string value2)<br><br>...this
 json.net formatter chokes on the json you send it (as opposed to when 
you just use the regular formatter) (say that json is 
{"value1":"one","value2":"two"} - the original formatter likes this, but
 the json.net formatter you use here doesn't).  It gives this exception:
 
{"ExceptionType":"Newtonsoft.Json.JsonSerializationException","Message":"Cannot
 deserialize JSON object into type 'System.String'. Line 1, position 
12.","StackTrace":"   at 
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader
 <br><br>Any ideas?</div><div class="commentBoxFooterStyle"><span class="commentPermalinkStyle">Jme1234</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="dfcc9ef8-68e1-47bf-9d35-0fc3dd5f3205"></a>Thursday, March 08, 2012 9:27:48 PM UTC</div><div class="commentBodyStyle">Maybe
 I don't totally get what the issue on the client is, but if KO cant' 
handle a json date, that's a KO problem isn't it?  That is, the 
templates aren't designed to handle dates. So if you wanted something 
that was formatted in a template, then you should pass a string in the 
first place, I would think.  I've never used that before so I am not 
sure why it would be this way, but I've never had any problems with JS 
dates on the client. I pass a date from code, it gets serialized into a 
wierd number, and JSON.parse turns it back into a date at the client.<br><br>More
 annoying is getting back what you started with on the server, here's my
 solution to that problem. I'm sure it could be shorter. <br><br>Changing the way dates are serialized sounds like a recipe for disaster, though, I mean it's not really valid JSON any more.<br><br><pre><br>    public static DateTime FromJSDateTime(string jsDateTime)<br>    {<br>         Regex regex = new Regex(@"^""\\/Date\((?&lt;ticks&gt;-?[0-9]+)\)\\/""");<br>         string ticks = regex.Match(jsDateTime).Groups["ticks"].Value;<br>         DateTime dt =  unixEpoch.AddMilliseconds(Convert.ToDouble(ticks));<br>         return DateTime.SpecifyKind(dt, DateTimeKind.Utc).ToLocalTime();<br>    }<br></pre></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_005.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://jamietre.myopenid.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">James Treworgy</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="a7a46ab8-2994-4e17-af21-72a5ac0890d1"></a>Thursday, March 08, 2012 11:07:01 PM UTC</div><div class="commentBodyStyle">I
 take back part of my previous comment... I forgot that actually *there 
is no (official) JSON standard for dates* :) But the rationale for using
 that format (e.g. it's parsable directly by JS and distinguishable from
 a string) makes some sense, and it's in common use, so changing it 
still seems  risky. <br><br>And ultimately why worry about parsing dates
 at the client if all you were going to do was turn it into a string? C#
 is much better for formatting strings than javascript!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_005.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://jamietre.myopenid.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">James Treworgy</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="68158199-2dbb-49e8-9adc-40b8bc25922a"></a>Friday, March 09, 2012 11:29:08 AM UTC</div><div class="commentBodyStyle">Web API rocks but the serialization issues would have been a *major* blunder if not fixed by RTM...<br><br>Adding
 Json.net will also help with other big issues like support untyped 
objects (type object), anonymous types, much better and two-way 
dictionary serialization, plus the ability to more easily plug in new 
converters if necessary in an easy way.<br><br>Adding Json.net is a 
great choice, but it's *stunning* to me that Microsoft couldn't get 
their own JSON serialization fixed with 3 different serialization tools 
(JavaScriptSerializer, DataContractJsonSerializer and now the new 
System.Json classes which are woefully incomplete and will compete with 
Json.net's feature set). Instead we'll have yet another DLL in the 
assembly soup that WebAPI adds to a project (can we get that 
consolidated please before RTM please???) and presumably in addition to 
System.Json which will add more confusion yet over what the right way to
 do low level JSON manipulation. &lt;sigh&gt; Two steps forward, one 
step back...<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_015.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://www.west-wind.com/weblog/">Rick Strahl</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="dd327bea-269b-4317-a341-f2c205fbe70e"></a>Monday, March 12, 2012 11:51:50 AM UTC</div><div class="commentBodyStyle">The
 first thing I was going to do with the Web API is make it play with 
JSON.NET now I don't have to :)  Web API using JSON.NET by default is 
awesome news thank you. <br><br>@Rob I also needed more control over 
JSON formatting, before I knew about Web API I created a 
JsonValueProviderFactory using JSON.NET. If you use my 
JsonValueProviderFactory and create a ActionResult that returns 
JsonConvert.SerializeObject(myModel); you will have completely swapped 
out the JavaScriptSerializer from MVC.<br><br>http://www.dalsoft.co.uk/blog/index.php/2012/01/10/asp-net-mvc-3-improved-jsonvalueproviderfactory-using-json-net/<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_007.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://www.dalsoft.co.uk/">DalSoft</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="9c78984d-fa0c-4deb-a4a0-dc3810ce65c6"></a>Monday, March 12, 2012 11:53:38 AM UTC</div><div class="commentBodyStyle"><a href="http://www.dalsoft.co.uk/blog/index.php/2012/01/10/asp-net-mvc-3-improved-jsonvalueproviderfactory-using-json-net/">http://www.dalsoft.co.uk/blog/index.php/2012/01/10/asp-net-mvc-3-improved-jsonvalueproviderfactory-using-json-net/</a></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_007.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://www.dalsoft.co.uk/">DalSoft</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="0c15aa55-d237-4a2b-b9a6-1d28f19bf662"></a>Wednesday, March 14, 2012 4:03:51 PM UTC</div><div class="commentBodyStyle">ISO 8601 date format is also supported in ServiceStack.Text now by set global configuration as:<br><br>JsConfig.DateHandler = JsonDateHandler.ISO8601;</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawncsYx8NXFTN9aARBov9G18kWBn_lrC7Nw"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Tien Do</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="9680dfb9-c2c9-4293-8e79-c975e869656e"></a>Tuesday, March 27, 2012 8:30:52 PM UTC</div><div class="commentBodyStyle">Scott, <br><br>One
 more pet peeve. Entity Framework returns DateTimes back as 
DateTimeKind.Unspecified. I save all of my DateTimes to the DB in UTC, 
but if the JSON serializer sees DateTimeKind.Unspecified, it figures it 
is local time and again, converts to UTC for a JSON Date(xxxxx) 
response. The result is double hour shifting!<br><br>I wrote a T4 
template that forces all retrieved DateTime objects from the DB to come 
back as DateTimeKind.UTC by default, but a simple config file flag to 
force EF to return them UTC, built in, would be A-W-E-S-O-M-E.<br><br>My blog post on this: http://www.aaroncoleman.net/post/2011/06/16/Forcing-Entity-Framework-to-mark-DateTime-fields-at-UTC.aspx<br><br>--Aaron<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_019.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkO14GAI0a2YiLxAeiHDtUsZqE-K8PoTN0"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Aaron Coleman</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="136e10d0-216e-4fa5-8f52-17bf06002989"></a>Thursday, April 05, 2012 8:43:57 AM UTC</div><div class="commentBodyStyle">You say dates are hard. They are hard indeed but not impossible, try json serializing EF 4.0 entities using webHttpBinding.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_019.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawnf4LcJ1zjb5zGhj9FoV1EgV9IVGnTDFi8"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Tanveer Badar</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="0cca7572-6540-4cbe-ba52-87a1a4ff5226"></a>Tuesday, April 17, 2012 12:35:25 PM UTC</div><div class="commentBodyStyle">It
 all blows - the proposed solution is horrendous as well. What if my 
string really looks like "2001-01-01T01:01:01Z" - the library is going 
to grab it and make it a date.<br><br>There is nothing wrong with duck 
typing, but 'suck' typing (portmanteau of string and duck) is just 
asking for trouble. How do you fix it? The best I can come up with is:<br><br><pre>{<br> "title": "test"<br> "posted": type.dateTime("2001-01-01T01:01:01Z")<br>}</pre><br><br>This
 retains the 'jsony' paradigm where if you executed the string you would
 get the correct object (even though you shouldn't). 'type' would simply
 be an object passed through with a couple of methods (from what I can 
tell, only 'dateTime' would actually be needed).</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_020.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://jonathan.dickinsons.co.za/blog/">Joanthan Dickinson</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="4a48ecba-0a3c-42d1-952f-af72f4cb107c"></a>Friday, July 06, 2012 7:52:57 PM UTC</div><div class="commentBodyStyle">Glad to see that JSON DateTime serialization is becoming more sane. No more ugly parsing!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_003.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawlv3KhsJL0XN4gsr9QeTrF1V--NE0vVGPc"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Roy Tinker</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="71f0b670-4c2a-46cb-be74-dce136192adb"></a>Thursday, July 26, 2012 8:20:55 AM UTC</div><div class="commentBodyStyle">Now
 in RC we get nice js iso dates from the WebAPI, BUT with   no timezone 
information. Why that? How to tell the formatter to always include the 
timezone?</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_020.png"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawkMmSO4O5eLjycaLk5MVEshnvRxfxtu640"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">phil jay</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="9b66bcc3-c2cc-4616-8eec-5ccc663d738a"></a>Tuesday, August 21, 2012 10:35:43 PM UTC</div><div class="commentBodyStyle">This example works perfectly:<br><br>var dataAUX = newcDate(parseInt(data.DataInicio.substr(6)));<br><br>var
 dataEND = dataAUX.getMonth() + 1 + "/" + dataAUX.getDate() + "/" + 
dataAUX.getFullYear() + "  " + dataAUX.getHours() + ":" + 
dataAUX.getMinutes() + ":" + dataAUX.getSeconds();<br><br>This Way You Will get the hours as well<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar.png"></span><span class="commentPermalinkStyle">José</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="a14d23e7-15e0-46d1-9cf1-a68062b6e21b"></a>Monday, August 27, 2012 8:32:44 PM UTC</div><div class="commentBodyStyle">I'm
 looking for a similar fix for WCF Data Services.  We have a client 
running into this, but who has specified MVC3/.NET4 (let me know if I'm 
confused on technologies here...)<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_022.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawn9OR4XaKWwPFLuJcsPfSyPAyZ3tv36FGI"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Daniel Root</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="ace9cd5b-219e-4be4-8778-8e592d40f6c9"></a>Tuesday, August 28, 2012 2:28:19 PM UTC</div><div class="commentBodyStyle">For
 anybody looking for a WCF Data Services solution, StackOverflow landed 
me on a solution: update to v5 and use oData v3: 
http://stackoverflow.com/questions/12148692/how-to-properly-handle-json-date-formatting-issues-for-wcf-data-services/12149363#12149363
 </div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_022.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="https://www.google.com/accounts/o8/id?id=AItOawn9OR4XaKWwPFLuJcsPfSyPAyZ3tv36FGI"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif">Daniel Root</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="2942203b-7134-4ff1-80c6-40aa86910f51"></a>Thursday, August 30, 2012 6:16:25 PM UTC</div><div class="commentBodyStyle">Is there a way to control/change the settings on the default JSNO.Net serializer? Or do I have to still do the swap with my own?</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_016.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://mrchief.myopenid.com/"><img class="commentOpenId" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/openid-icon-small.gif"></a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="386f0e02-9e74-438b-ac8b-da11296e6da3"></a>Sunday, October 14, 2012 1:04:33 AM UTC</div><div class="commentBodyStyle">People say I'm crazy to hand write the json but this is a perfect example why.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_017.png"></span><span class="commentPermalinkStyle">Mike</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="3c5d6117-c66b-4e7b-b48f-a13a9706e39a"></a>Friday, December 14, 2012 9:56:23 PM UTC</div><div class="commentBodyStyle">Hey Scott, is this an IE9 bug?<br><br>http://stackoverflow.com/questions/13886642/json-iso8601-parsing-in-javascript<br><br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_018.jpg"></span><a class="commentPermalinkStyle" rel="nofollow" href="http://seerobcode.com/">rob koch</a></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="09f6df1e-f542-43f3-b4cd-f85d54a869df"></a>Tuesday, March 19, 2013 9:01:45 PM UTC</div><div class="commentBodyStyle">So,
 did ASP.NET MVC 4 ship with JSON.net as the default formatter?  Looking
 at the wire I still see date times in this format 
Date(1330848000000-0800)?<br></div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_002.png"></span><span class="commentPermalinkStyle">Scott Smith</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="272890ad-763c-4b32-aa0f-dadd483cfade"></a>Tuesday, April 02, 2013 7:43:28 PM UTC</div><div class="commentBodyStyle">Thanks man.! #Useful .. </div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_006.jpg"></span><span class="commentPermalinkStyle">Wilson Rivera</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="15e066fa-dd8d-478b-b2df-888e197f5cb1"></a>Monday, May 20, 2013 2:39:41 PM UTC</div><div class="commentBodyStyle">Link is broken. <br><br>https://www.twitter.com/statuses/public_timeline.json</div><div class="commentBoxFooterStyle"><span class="commentPermalinkStyle">Joe</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="aebadaf9-3c7f-47e0-8a91-7a0066da1087"></a>Friday, May 31, 2013 9:38:59 AM UTC</div><div class="commentBodyStyle">Doesn't
 replacing the json serializer bypass MVC's default output sanitizer and
 therefore potentially expose XSS threats? Make sure you manually 
sanitize after serialize or include the sanitizing in the serializer!</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_014.jpg"></span><span class="commentPermalinkStyle">Mark</span></div></div><div class="commentBoxStyle"><div class="commentDateStyle"><a name="0d777cd0-4b47-4ba7-b074-7de55ff95032"></a>Tuesday, June 04, 2013 5:36:22 PM UTC</div><div class="commentBodyStyle">It's
 too bad posting a date to MVC causes it to convert it from UTC to local
 server timezone, which can push the date part into the previous day.  
The lack of a date type in .NET is another source of nightmares.</div><div class="commentBoxFooterStyle"><span class="commentGravatarBlock"><img class="commentGravatar" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/avatar_012.jpg"></span><span class="commentPermalinkStyle">AaronLS</span></div></div></div>
    <div id="commentViewEntry" class="commentViewBoxStyle">
        <span id="ctl01_commentsClosed" style="text-align: center">
            <span id="ctl01_labelCommentsClosed" class="commentViewLabelStyle">Comments are closed.</span>
        </span>
        
        
    </div>
</div>

</main>
<section class="containerOuter blogBodyContainer">
 <section class="containerInner blogBody">
				<div id="paging">
						<div class="paging-prev">
							
						</div>
						<div class="paging-next">
							
						</div>
						
				</div>
    </section>
</section>


<section class="containerOuter line-tan" id="disclaimer">
	<section class="containerInner">
		<p>Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.</p>

    </section>
</section>



<footer class="containerOuter line-darkbrown">
	<section class="containerInner">
        
        <div class="footer-container">
        	<h3>Blog</h3>
            <ul>
            	<li><a href="http://www.hanselman.com/">Latest</a></li>
                <li><a href="http://www.hanselman.com/blog/GreatestHits.aspx">Greatest Hits</a></li>
                <li><a href="http://www.hanselman.com/tools">Dev Tool List</a></li>                
            </ul>
        </div>
        
        <div class="footer-container">
        	<h3>Podcast</h3>
            <ul>
            	<li><a href="http://hanselminutes.com/">Hanselminutes</a></li>
                <li><a href="http://thisdeveloperslife.com/">This Developer's Life</a></li>
                <li><a href="http://ratchetandthegeek.com/">Ratchet &amp; The Geek</a></li>                
            </ul>
        </div>
        
        <div class="footer-container">
        	<h3>Speaking</h3>
            <ul>
            	<li><a href="http://www.hanselman.com/blog/CategoryView.aspx?category=Speaking">Speaking/Videos</a></li>
                <li><a href="http://www.speakinghacks.com/">Presentations Tips</a></li>
            </ul>
        </div>
        
        <div class="footer-container">
        	<h3>Books</h3>
            <ul>
            	<li><a href="https://www.amazon.com/gp/product/1118311825/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=1118311825&amp;linkCode=as2&amp;tag=diabeticbooks">ASP.NET 4.5</a></li>
                <li><a href="https://www.amazon.com/gp/product/111834846X/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=111834846X&amp;linkCode=as2&amp;tag=diabeticbooks">ASP.NET MVC 4</a></li>
                <li><a href="http://relationshiphacks.com/">Relationship Hacks</a></li>                
            </ul>
        </div> 
    </section>
	<div class="copyright">© Copyright 2015, <a href="https://www.hanselman.com/">Scott Hanselman</a>. Design by <a href="http://www.8164.org/">@jzy</a></div>        
</footer>

 <script language="javascript">
    <!--
    function escapeString(searchString)
    {
      var newString = escape(searchString);
      return newString;
    }

    function doSearch(searchString)
    {
      if (searchString != "")
      {
        location.href='//www.hanselman.com/blog/googleresults.html?&sa=Search&domains=www.hanselman.com&sitesearch=www.hanselman.com&client=pub-7789616507550168&forid=1&ie=UTF-8&oe=UTF-8&safe=active&cof=GALT%3A%23B47B10%3BGL%3A1%3BDIV%3A%23A9501B%3BVLC%3A6F3C1B%3BAH%3Acenter%3BBGC%3AFFFFFF%3BLBGC%3A336699%3BALC%3AB47B10%3BLC%3AB47B10%3BT%3A000000%3BGFNT%3AA9501B%3BGIMP%3AA9501B%3BFORID%3A11&hl=en&q=' + escapeString(searchString);
      }
      return false;
    }
    -->
  </script>
          
  <script src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/footer.js"></script>
        
  <script type="text/javascript">
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-130207-1']);
	  _gaq.push(['_trackPageview']);

	  (function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();

	</script>

	<noscript><a href='https://www.omniture.com' title='Web Analytics'><img src='https://mssto.112.2o7.net/b/ss/msstoextblogsnojs/1/H.20.2--NS/0'  height='1' width='1' border='0' alt='' /></a></noscript>

	<script type="text/javascript">
		SyntaxHighlighter.config.bloggerMode = true;
		SyntaxHighlighter.config.stripBrs = true;
		SyntaxHighlighter.defaults['auto-links'] = false;
		SyntaxHighlighter.all();
		dp.SyntaxHighlighter.HighlightAll('code');
	</script>


<!-- lake quincy -->
<script type="text/javascript">
    function _dmBootstrap(file) { 
        var _dma = document.createElement('script');  
        _dma.type = 'text/javascript'; 
        _dma.async = true;  
        _dma.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + file; 
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(_dma);
    }
    function _dmFollowup(file) { if (typeof DMAds === 'undefined')  _dmBootstrap('cdn2.DeveloperMedia.com/a.min.js');}
    (function () { _dmBootstrap('cdn1.DeveloperMedia.com/a.min.js'); setTimeout(_dmFollowup, 2000);})();
</script>
        
        
  <!--  Place this tag after the last plusone tag -->
	<script type="text/javascript">
	  (function() {
		var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
		po.src = 'https://apis.google.com/js/plusone.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
	  })();
	</script>

  <script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
			$("section .blogBody a:[href$=.jpg],a[href$=.png],a[href$=.gif]").fancybox();
		});
	</script>

<input name="OBKey" value="zbWJu9GRhQQRrmDBvuZY/A==" type="hidden"> <script language="JavaScript">var OBCTm='1370325530403'; </script><script language="JavaScript" src="On%20the%20nightmare%20that%20is%20JSON%20Dates.%20Plus,%20JSON.NET%20and%20ASP.NET%20Web%20API%20-%20Scott%20Hanselman_files/claim.js"></script>

</form>


<div id="fancybox-tmp"></div><div id="fancybox-loading"><div></div></div><div id="fancybox-overlay"></div><div id="fancybox-wrap"><div id="fancybox-outer"><div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div><div id="fancybox-content"></div><a id="fancybox-close"></a><div id="fancybox-title"></div><a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a><a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a></div></div><iframe style="display: none;" allowtransparency="true" scrolling="no" id="rufous-sandbox" frameborder="0"></iframe></body></html>